package com.epalmpay.controller.manage.datareport;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.epalmpay.commom.BaseController;
import com.epalmpay.exception.ApplicationException;
import com.epalmpay.status.Rescode;
import com.epalmpay.dto.manage.datareport.ManageDataReportInDTO;
import com.epalmpay.dto.manage.datareport.ManageDataReportListOutDTO;
import com.epalmpay.entity.StatisEpalmpayDay;
import com.epalmpay.entity.StatisEpalmpayMonth;
import com.epalmpay.service.datareport.IManageDataReportService;

/** 
 * 说明：数据报表 :数据简报
 * 创建人：gwn
 * 创建时间：2017-06-20
 */
@Controller
@RequestMapping(value="/manager")
public class ManageDataReportController  extends BaseController{

	@Resource
	private IManageDataReportService manageDataReportService;
	
	@RequestMapping(value="/manageDataReport")
	@ResponseBody
	public ManageDataReportListOutDTO List(ManageDataReportInDTO manageDataReportInDTO){
		
		ManageDataReportListOutDTO manageDataReportListOutDTO= new ManageDataReportListOutDTO();
		try {
			if (manageDataReportInDTO.getQueryDayOrMonth()==1) {
				if (manageDataReportInDTO.getJoinStart()==null) {
					manageDataReportInDTO.setJoinStart(new Date());
				}
				 StatisEpalmpayDay statisEpalmpayDay=manageDataReportService.queryManageStatisEpalmpayDay(manageDataReportInDTO);
				 manageDataReportListOutDTO.setStatisEpalmpayDay(statisEpalmpayDay);
			}else{
				 StatisEpalmpayMonth statisEpalmpayMonth =manageDataReportService.queryManageStatisEpalmpayMonth(manageDataReportInDTO);
				 manageDataReportListOutDTO.setStatisEpalmpayMonth(statisEpalmpayMonth);
			}
			manageDataReportListOutDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
			return manageDataReportListOutDTO;
		} catch (ApplicationException ae) { 
			manageDataReportListOutDTO.setErrorCode(ae.errCode, ae.errMsg);
			ae.printStackTrace();
		}
		catch (Exception e) {
			manageDataReportListOutDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
				e.printStackTrace();
		}
		return manageDataReportListOutDTO;
		
	}
	
	
}
